import handler.PrintStringHandler;
import handler.WriteMsgHandler;
import my.netty.bootstrap.ServerBootstrap;
import my.netty.channel.Channel;
import my.netty.channel.EventLoopGroup;
import my.netty.channel.ServerChannel;
import my.netty.channel.handler.AbstractChannelHandlerContext;
import my.netty.channel.handler.ChannelInboundHandler;
import my.netty.channel.handler.ChannelInitializer;
import my.netty.channel.handler.SimpleChannelInboundHandler;
import my.netty.channel.nio.NioEventLoopGroup;
import my.netty.channel.nio.NioServerSocketChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;

public class SimpleServer {
    public static void main(String[] args) throws IOException {
        EventLoopGroup bossGroup = new NioEventLoopGroup(1);
        EventLoopGroup workerGroup = new NioEventLoopGroup(2);
        ServerBootstrap bootstrap = new ServerBootstrap();
        bootstrap.channel(NioServerSocketChannel.class).group(bossGroup, workerGroup)
                .childHandler(new ChannelInitializer() {
                    @Override
                    public void initChannel(Channel channel) {
                        channel.pipeline().addFirst(new WriteMsgHandler())
                                .addFirst(new PrintStringHandler())
                                ;
                    }
                })
                .bind(8080);
    }
}
